#ifndef BIGQ_H
#define BIGQ_H
#include <pthread.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include "Pipe.h"
#include "File.h"
#include "Record.h"
#include "Schema.h"
#include "ComparisonEngine.h"
#include "Comparison.h"
#include <math.h>
#include <queue>

using namespace std;

class BigQ {

public:

	BigQ (Pipe &in, Pipe &out, OrderMaker &sortorder, int runlen);
	~BigQ ();

};

class ExternalSort {

public:
	Pipe* inputpipe;
	Pipe* outputpipe;
	int passedrunlen;
	OrderMaker* tempOrderMaker;
//	static int cnt;
	int totalRuns,countPagesInRun,countRecordsInRunLength;
	File myFile;
	int page_in_file;
	vector<Record*> sortingArray;
	Page bufferPage;
	int runIndex;
	//Record* tempRecord;


	ExternalSort();
	static bool comparingvector(Record* left,Record* right);
	virtual ~ExternalSort();
	void RunGeneration();
	void RunMerging();
	void dumpOnDisk();
	int GetPageOffset();

};

#endif
